var top1 = document.querySelector("#top");

window.onscroll = function(){
    if(document.documentElement.scrollTop > 400 || document.body.scrollTop > 400){
        top1.style.display = "block";
    }else {
        top1.style.display = "none"
    }
};

top1.addEventListener('click',function(){
   window.scrollTo(0,0);

});